package com.all.springdoc.controller;

import com.all.springdoc.pojo.UserDO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @Author LY
 * @create 2024/2/26 11:36
 * @Description 用户控制层
 */
@Tag(name = "UserController", description = "用户管理")
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Operation(summary = "查询用户")
    @GetMapping("/query")
    public UserDO query(@Parameter(name = "name", description = "名称") String name) {
        log.info("查询用户|query");
        UserDO userDO = new UserDO();
        userDO.setName(name);
        return userDO;
    }

    @Operation(summary = "用户列表")
    @GetMapping("/list")
    public List<UserDO> list() {
        log.info("获取用户列表|list");
        return new ArrayList<UserDO>();
    }

    @Operation(summary ="添加用户")
    @PostMapping("/add")
    public UserDO add(UserDO userDO) {
        log.info("添加用户|add");
        return new UserDO();
    }

    @Operation(summary ="更新用户")
    @PostMapping("/update")
    public UserDO update(UserDO userDO) {
        log.info("更新用户|update");
        return new UserDO();
    }

    @Operation(summary ="删除用户")
    @PostMapping("/delete")
    public Boolean delete(Integer id) {
        log.info("删除用户|delete|{}", id);
        return true;
    }
}
